package amazon

import (
	"black_mamba/global"
	"black_mamba/pages"
	"black_mamba/workers"
	_ "embed"
	"fmt"
	"gitee.com/wengo/windows_gui/widget"
	"gitee.com/wengo/windows_gui/xc"
	"github.com/tidwall/gjson"
	"strconv"
	"sync"
	"time"
	"unsafe"
)

type DealsPagePage struct {
	pages.Foundation
	style        map[string]int
	taskTotal    *widget.ShapeText
	detailLayout *widget.LayoutEle
	FastMode     bool
}

func NewDealsPagePage() *DealsPagePage {

	dealsPage := &DealsPagePage{
		Foundation: pages.Foundation{
			ExecuteBtn: widget.NewButtonByName("bdExecuteBtn"),
			LogEdit:    widget.NewEditByName("bdLogEdit"),
			Style:      nil,
			Topic:      "deals",
			//ListBoxLayout: widget.NewLayoutEleByName("bdListBoxLayout"),
			//ParentLayout:  widget.NewLayoutEleByName("bdParentLayout"),
		},
		taskTotal:    widget.NewShapeTextByName("taskTotal"),
		detailLayout: widget.NewLayoutEleByName("detailLayout"),
	}

	// 绑定执行按钮事件
	dealsPage.ExecuteBtn.Event_BnClick(dealsPage.execute)

	// 设置log样式
	dealsPage.SetEditStyle()

	// 创建listbox
	dealsPage.NewListBox("bdListBox", "bd_list.xml")

	//绑定所有订阅
	dealsPage.Subscribes()

	//自定义订阅
	dealsPage.customSubscribes()

	// 设置listbox的按钮事件
	//dealsPage.ListBox.RegEventC(xcc.XE_LISTBOX_TEMP_CREATE_END, func(pItem *xc.ListBox_Item_, nFlag int, pbHandled *bool) int {
	//	itemViewBtn := widget.NewButtonByHandle(dealsPage.ListBox.GetTemplateObject(int(pItem.Index), 1))
	//	itemViewBtn.Event_BnClick(func(pbHandled *bool) int {
	//		index := dealsPage.ListBox.GetItemIndexFromHXCGUI(itemViewBtn.Handle)
	//		asin := dealsPage.ListBox.GetItemText(index, 1)
	//		wapi.ShellExecuteW(1, "open", `C:\Program Files\Google\Chrome\Application\chrome.exe`, fmt.Sprintf("https://www.amazon.com/dp/%s", asin), "", 3)
	//		return 0
	//	})
	//	return 0
	//})
	return dealsPage
}

//注册所有订阅者
func (b *DealsPagePage) customSubscribes() {

	//订阅任务总数
	updateTaskTotal := b.updateTaskTotal
	_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:taskTotal", b.Topic), func(data map[string]int) {
		xc.XC_CallUiThread(updateTaskTotal, int(uintptr(unsafe.Pointer(&data))))
	})

	//订阅任务反馈
	updateFeedBack := b.updateFeedBack
	_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:feedback", b.Topic), func(data map[interface{}]uint) {
		xc.XC_CallUiThread(updateFeedBack, int(uintptr(unsafe.Pointer(&data))))
	})

	addData := b.AddData
	_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:addData", b.Topic), func(data map[string]interface{}) {
		xc.XC_CallUiThread(addData, int(uintptr(unsafe.Pointer(&data))))
	})

	updateData := b.UpdateData
	_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:updateData", b.Topic), func(data map[string]interface{}) {
		xc.XC_CallUiThread(updateData, int(uintptr(unsafe.Pointer(&data))))
	})

	deleteData := b.DeleteData
	_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:deleteData", b.Topic), func(data string) {
		xc.XC_CallUiThread(deleteData, int(uintptr(unsafe.Pointer(&data))))
	})

	//endTaskFeedback := b.DeleteData
	//_ = global.BM_EVENTBUS.Subscribe(fmt.Sprintf("%s:endTaskFeedback", b.Topic), func(data string) {
	//	xc.XC_CallUiThread(deleteData, int(uintptr(unsafe.Pointer(&data))))
	//})

}

/* 事件回调 */
func (b *DealsPagePage) execute(pbHandled *bool) int {
	*pbHandled = true

	if global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value() == "" {
		b.UpdateLog(int(uintptr(unsafe.Pointer(&(map[string]string{"status": "error", "content": "请先设置机器序列号"})))))
		return 0
	}

	if global.BM_CONFIG.Section("proxy").Key("username").Value() == "" {
		b.UpdateLog(int(uintptr(unsafe.Pointer(&(map[string]string{"status": "error", "content": "请先设置代理用户名"})))))
		return 0
	}

	if global.BM_CONFIG.Section("proxy").Key("password").Value() == "" {
		b.UpdateLog(int(uintptr(unsafe.Pointer(&(map[string]string{"status": "error", "content": "请先设置代理密码"})))))
		return 0
	}

	//重绘父
	b.ToggleBtn(int(uintptr(unsafe.Pointer(b.ExecuteBtn))))

	go func() {

		//rankWorker := workers.NewRankWorker()
		//rankWorker.Execute(map[string]interface{}{
		//	"website": "www.amazon.com",
		//})

		//b.monitorMode()

		tableData := map[string]interface{}{
			"headers": []string{"id", "group", "task_name", "asin", "seller_id", "country", "total"},
			"body":    []map[string]string{},
		}

		var taskWg sync.WaitGroup
		//var chans []chan interface{}

		var reset = true
		ticker := time.NewTicker(1 * time.Second)

		var chans []chan interface{}

		for {
			<-ticker.C
			taskTotalInfo := global.BM_API.GetTaskTotal(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value())
			taskTotal := gjson.Get(taskTotalInfo, "data.current_bind_task_total.value").Int()
			taskGroupTotal := gjson.Get(taskTotalInfo, "data.bind_task_group_total.value").Int()
			//
			//taskTotal = 1
			//taskData := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"10","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09KS1C4NW"},"keywords":{"title":"关键词","value":"B09KS1C4NW"},"seller_id":{"title":"Seller ID","value":"ASZYUKDU1B82R"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//taskData := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"10","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B0B79JK24J"},"keywords":{"title":"关键词","value":"B0B79JK24J"},"seller_id":{"title":"Seller ID","value":"A2ZM6G2TP9561O"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//taskData := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"10","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09ZV4LBXK"},"keywords":{"title":"关键词","value":"B0B79JK24J"},"seller_id":{"title":"Seller ID","value":"A3SMZ1NYGRWP27"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//taskData = `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"1","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09XHMGRC5"},"keywords":{"title":"关键词","value":"B0B79JK24J"},"seller_id":{"title":"Seller ID","value":"A2TPU523YC9RHN"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`

			if taskTotal > 0 && global.BM_POOL.Running() < int(taskTotal) {

				taskData := global.BM_API.GetTaskList(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value(), "4.9", reset)
				//taskData := global.BM_API.GetTaskList(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value(), "4.10", reset)
				global.BM_EVENTBUS.Publish("deals:taskTotal", map[string]int{"taskGroupTotal": int(taskGroupTotal), "taskTotal": int(taskTotal)})

				//if gjson.Get(taskData, "status").String() == "error" {
				//	global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "error", "content": gjson.Get(taskData, "reason").String()})
				//	continue
				//}

				var body []map[string]string
				for _, task := range gjson.Get(taskData, "data.tasks").Array() {
					for _, d := range gjson.Get(task.String(), "list").Array() {
						id := gjson.Get(d.String(), "task_id.value").String()
						group := gjson.Get(d.String(), "group_name.value").String()
						name := gjson.Get(d.String(), "name.value").String()
						asin := gjson.Get(d.String(), "asin.value").String()
						sellerId := gjson.Get(d.String(), "seller_id.value").String()
						code := gjson.Get(d.String(), "code.value").String()
						body = append(body, map[string]string{
							"id":        id,
							"group":     group,
							"task_name": name,
							"asin":      asin,
							"seller_id": sellerId,
							"country":   code,
						})
					}
				}

				tableData["body"] = body

				// 更新列表
				global.BM_EVENTBUS.Publish("deals:addData", tableData)
				dealsWorker := workers.NewDealsCheckoutWorker()

				var ch = make(chan interface{})
				chans = append(chans, ch)

				for _, task := range gjson.Get(taskData, "data.tasks").Array() {
					list := task.String()
					err := global.BM_POOL.Submit(dealsWorker.Decorator(dealsWorker.Execute, map[string]interface{}{
						"tasks":     list,
						"pauseTime": gjson.Get(taskData, "data.machine.executeTimeout.value").Int(),
						"group":     gjson.Get(task.String(), "task_group_name.value").String(),
						"proxy":     fmt.Sprintf("FE6FC783:E0C53AF2F7CD@%s", gjson.Get(taskData, "data.proxy.host.value").String()),
					}, &taskWg, nil))
					if err != nil {
						return
					}
					//ticker.Stop()
				}

				fmt.Println(global.BM_POOL.Running())
			} else if global.BM_POOL.Running() == 0 {
				global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "info", "content": "暂无任务需要执行,1分钟再请求"})
			}

			reset = false
		}

		for {
			// 获取任务
			data := global.BM_API.GetTaskList(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value(), "4.8", false) // 美国

			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"5","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B08L7K7QJJ"},"keywords":{"title":"关键词","value":"B08L7K7QJJ"},"seller_id":{"title":"Seller ID","value":"AZWRYG4A5FSSR"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}},{"task_id":{"title":"任务ID","value":"6936"},"task_group_id":{"title":"任务组ID","value":"6936"},"name":{"title":"任务名","value":"lsy5.2柴火架"},"task_group_name":{"title":"任务组名","value":"lsy5.2柴火架"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09LLRD816"},"keywords":{"title":"关键词","value":"B09LLRD816"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":"柴火架"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41505"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]},{"task_group_name":"组3","list":[{"task_id":{"title":"任务ID","value":"6937"},"task_group_id":{"title":"任务组ID","value":"6937"},"name":{"title":"任务名","value":"JLF5.2哑铃"},"task_group_name":{"title":"任务组名","value":"JLF5.2哑铃"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B0937KTSF2"},"keywords":{"title":"关键词","value":"B0937KTSF2"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":""},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41511"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}},{"task_id":{"title":"任务ID","value":"6934"},"task_group_id":{"title":"任务组ID","value":"6934"},"name":{"title":"任务名","value":"lsy5.2跳舞毯"},"task_group_name":{"title":"任务组名","value":"lsy5.2跳舞毯"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09MQKVC74"},"keywords":{"title":"关键词","value":"B09MQKVC74"},"seller_id":{"title":"Seller ID","value":"AJD69LYDPC95"},"category_name":{"title":"分类名称","value":"AJD69LYDPC95"},"product_name":{"title":"产品名","value":"跳舞毯"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41534"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]},{"task_group_name":"组5","list":[{"task_id":{"title":"任务ID","value":"6935"},"task_group_id":{"title":"任务组ID","value":"6935"},"name":{"title":"任务名","value":"lsy5.2看台椅"},"task_group_name":{"title":"任务组名","value":"lsy5.2看台椅"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09GVF3DHN"},"keywords":{"title":"关键词","value":"B09GVF3DHN"},"seller_id":{"title":"Seller ID","value":"AJD69LYDPC95"},"category_name":{"title":"分类名称","value":"AJD69LYDPC95"},"product_name":{"title":"产品名","value":"看台椅"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41538"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}},{"task_id":{"title":"任务ID","value":"6938"},"task_group_id":{"title":"任务组ID","value":"6938"},"name":{"title":"任务名","value":"江飞5.2抱枕"},"task_group_name":{"title":"任务组名","value":"江飞5.2抱枕"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09JWWSQBJ"},"keywords":{"title":"关键词","value":"B09JWWSQBJ"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":"抱枕"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41523"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"5","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组3","list":[{"task_id":{"title":"任务ID","value":"6938"},"task_group_id":{"title":"任务组ID","value":"6938"},"name":{"title":"任务名","value":"江飞5.2抱枕"},"task_group_name":{"title":"任务组名","value":"江飞5.2抱枕"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09JWWSQBJ"},"keywords":{"title":"关键词","value":"B09JWWSQBJ"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":"抱枕"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41523"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}},{"task_id":{"title":"任务ID","value":"6934"},"task_group_id":{"title":"任务组ID","value":"6934"},"name":{"title":"任务名","value":"lsy5.2跳舞毯"},"task_group_name":{"title":"任务组名","value":"lsy5.2跳舞毯"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09MQKVC74"},"keywords":{"title":"关键词","value":"B09MQKVC74"},"seller_id":{"title":"Seller ID","value":"AJD69LYDPC95"},"category_name":{"title":"分类名称","value":"AJD69LYDPC95"},"product_name":{"title":"产品名","value":"跳舞毯"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41534"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"5","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组3","list":[{"task_id":{"title":"任务ID","value":"6938"},"task_group_id":{"title":"任务组ID","value":"6938"},"name":{"title":"任务名","value":"江飞5.2抱枕"},"task_group_name":{"title":"任务组名","value":"江飞5.2抱枕"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09JWWSQBJ"},"keywords":{"title":"关键词","value":"B09JWWSQBJ"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":"抱枕"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41523"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"127.0.0.1:8080","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"5","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"webdriver_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":{"title":"任务组名","value":"YanTaiYaQiBoQuanBianMinBaiHuoYouXianGongSi"},"list":[{"task_id":{"title":"任务ID","value":"6937"},"task_group_id":{"title":"任务组ID","value":"6937"},"name":{"title":"任务名","value":"JLF5.2哑铃"},"task_group_name":{"title":"任务组名","value":"JLF5.2哑铃"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B0937KTSF2"},"keywords":{"title":"关键词","value":"B0937KTSF2"},"seller_id":{"title":"Seller ID","value":"A1QP74AMEP5ZPL"},"category_name":{"title":"分类名称","value":"A1QP74AMEP5ZPL"},"product_name":{"title":"产品名","value":""},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41594"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"127.0.0.1:8080","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"5","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"webdriver_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":{"title":"任务组名","value":"YanTaiYaQiBoQuanBianMinBaiHuoYouXianGongSi"},"list":[{"task_id":{"title":"任务ID","value":"6937"},"task_group_id":{"title":"任务组ID","value":"6937"},"name":{"title":"任务名","value":"JLF5.2哑铃"},"task_group_name":{"title":"任务组名","value":"JLF5.2哑铃"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B091GZWCCL"},"keywords":{"title":"关键词","value":"B091GZWCCL"},"seller_id":{"title":"Seller ID","value":"A2I9USXDHMOVAW"},"category_name":{"title":"分类名称","value":"A2I9USXDHMOVAW"},"product_name":{"title":"产品名","value":""},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41594"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}},{"task_id":{"title":"任务ID","value":"6937"},"task_group_id":{"title":"任务组ID","value":"6937"},"name":{"title":"任务名","value":"JLF5.2哑铃"},"task_group_name":{"title":"任务组名","value":"JLF5.2哑铃"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B094Y7LYTQ"},"keywords":{"title":"关键词","value":"B094Y7LYTQ"},"seller_id":{"title":"Seller ID","value":"A2I9USXDHMOVAW"},"category_name":{"title":"分类名称","value":"A2I9USXDHMOVAW"},"product_name":{"title":"产品名","value":""},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.com"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41594"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`
			// 德国
			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"10","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09NNKFRGC"},"keywords":{"title":"关键词","value":"B09NNKFRGC"},"seller_id":{"title":"Seller ID","value":"AT2S1HE8GYAM3"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.de"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"de"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.com"},"code":{"title":"国家代号","value":"us"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`

			//data := `{"status":"success","data":{"machine":{"machine_id":{"title":"机器ID","value":"vps.ueuz.com:55404","type":"input"},"executeTimeout":{"title":"最长时间(分)","value":"10","type":"input"},"privacy":{"close_image":{"title":"关闭图片","value":"true","type":"checkbox"},"close_flash":{"title":"关闭Flash","value":"true","type":"checkbox"}},"speed":{"title":"浏览速度","value":"0.5","type":"input"},"executeMethod":{"title":"执行模式","value":"http_method","type":"radio"},"browse":{"title":"浏览器","value":"chrome","type":"radio"},"proxyType":{"title":"代理类型","value":"vpn","type":"radio"},"proxy_address":{"title":"代理地址","value":"","type":"input"},"timeout":{"title":"发包超时时间","value":"60","type":"input"},"concurrent":{"title":"并发发包数","value":"5","type":"input"},"machineTypeGroup":{"title":"机器类型组","value":1,"type":"select"},"machineType":{"title":"任务类型","value":2,"type":"select"}},"tasks":[{"task_group_name":"组1","list":[{"task_id":{"title":"任务ID","value":"6929"},"task_group_id":{"title":"任务组ID","value":"6929"},"name":{"title":"任务名","value":"李帅5.2高尔夫推杆"},"task_group_name":{"title":"任务组名","value":"李帅5.2高尔夫推杆"},"task_delay":{"title":"延迟执行(分钟)","value":"0"},"success":{"title":"成功数","value":"0"},"target":{"title":"目标数","value":"10000"},"asin":{"title":"ASIN","value":"B09NNKFRGC"},"keywords":{"title":"关键词","value":"B09NNKFRGC"},"seller_id":{"title":"Seller ID","value":"AT2S1HE8GYAM3"},"category_name":{"title":"分类名称","value":"AZWRYG4A5FSSR"},"product_name":{"title":"产品名","value":"高尔夫推杆"},"shopping_cart_rate":{"title":"购物车率","value":"100"},"wishlist_rate":{"title":"心愿单率","value":"0"},"website":{"title":"目标网站","value":"www.amazon.ca"},"search_method":{"title":"搜索方式","value":"store"},"payment_method":{"title":"付款方式","value":"credit_card"},"is_referrer":{"title":"设置来源","value":"false"},"code":{"title":"国家代号","value":"ca"},"lang_code":{"title":"语言","value":"en-US"},"task_type":{"title":"任务类型","value":"login_add_cart_task"},"use_proxy":{"title":"使用代理","value":"false"},"concurrent_num":{"title":"concurrent_num","value":"5"},"register_method":{"title":"是否发包","value":"http"},"payment_type":{"title":"付款类型","value":"no_payment"},"address_type":{"title":"地址选项","value":""},"creditcard_type":{"title":"信用卡选项","value":""},"is_check_cart":{"title":"检查购物车","value":"false"},"account_type":{"title":"账户类型","value":"login"},"page_range":{"title":"页码范围","value":"20"},"click_ads":{"title":"点击广告","value":""},"intelligent_page":{"title":"智能页码","value":""},"is_brand":{"title":"开启品牌","value":"false"},"brand_name":{"title":"品牌名称","value":""},"qty":{"title":"加购数量","value":"166"},"is_checkout":{"title":"是否付款","value":"0"},"is_verify_account":{"title":"验证账户","value":"0"},"is_check_review":{"title":"检查评论","value":"0"},"is_check_review_then_quit":{"title":"检查评论后退出","value":"false"},"is_check_stock":{"title":"检查库存","value":"0"},"related_asin_list":{"title":"关联ASIN列表","value":""},"blacklist":{"title":"黑名单","value":""},"login_add_cart_task_list_id":{"title":"login_add_cart_task_list_id","value":"41487"},"review_asin":{"title":"留评ASIN","value":""},"review_title":{"title":"留评标题","value":""},"review_comment":{"title":"留评内容","value":""},"review_rating":{"title":"星级","value":""},"review_id":{"title":"评论模板ID","value":""},"review_images":{"title":"评论图片","value":""}}]}],"account":{"name":{"title":"帐户名","value":"None"},"email":{"title":"邮箱","value":"None"},"password":{"title":"密码","value":"None"},"website":{"title":"目标网站","value":"www.amazon.ca"},"code":{"title":"国家代号","value":"ca"},"lang_code":{"title":"语言","value":"en-US"},"cookie":{"title":"缓存","value":""}}}}`

			if gjson.Get(data, "status").String() != "success" {
				global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "info", "content": "暂无任务需要执行, 暂停1分钟再请求"})
				//xc.XC_CallUiThread(updateLog, int(uintptr(unsafe.Pointer(&(map[string]string{"status": "info", "content": "暂无任务需要执行, 暂停1分钟再请求"})))))
				time.Sleep(1 * time.Minute)
				continue
			}

			global.BM_EVENTBUS.Publish("deals:clearLog")
			global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "success", "content": "成功获取任务"})
			global.BM_EVENTBUS.Publish("deals:taskTotal", map[string]int{"taskGroupTotal": int(gjson.Get(data, "data.task_group_total.value").Int()), "taskTotal": int(gjson.Get(data, "data.task_total.value").Int())})

			delay := gjson.Get(data, "data.machine.executeTimeout.value").Int()

			//delay = 10

			var body []map[string]string
			for _, task := range gjson.Get(data, "data.tasks").Array() {
				for _, d := range gjson.Get(task.String(), "list").Array() {
					id := gjson.Get(d.String(), "task_id.value").String()
					group := gjson.Get(d.String(), "group_name.value").String()
					name := gjson.Get(d.String(), "name.value").String()
					asin := gjson.Get(d.String(), "asin.value").String()
					sellerId := gjson.Get(d.String(), "seller_id.value").String()
					code := gjson.Get(d.String(), "code.value").String()
					body = append(body, map[string]string{
						"id":        id,
						"group":     group,
						"task_name": name,
						"asin":      asin,
						"seller_id": sellerId,
						"country":   code,
					})
				}
			}

			tableData["body"] = body

			// 更新列表
			global.BM_EVENTBUS.Publish("deals:updateTable", tableData)

			fastMode := false

			if fastMode {
				var taskWg sync.WaitGroup
				for {

					if global.BM_POOL.Running() < 10 {
						dealsWorker := workers.NewDealsCheckoutWorker()
						tasks := global.BM_API.GetTaskList(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value(), "4.9", false) // 美国
						for _, task := range gjson.Get(tasks, "data.tasks").Array() {
							list := task.String()

							err := global.BM_POOL.Submit(dealsWorker.Decorator(dealsWorker.Execute, map[string]interface{}{
								"tasks": list,
								"mode":  "fastMode",
							}, &taskWg, nil))
							if err != nil {
								return
							}
							//break
						}
					}
				}
			} else {
				dealsWorker := workers.NewDealsCheckoutWorker()
				var taskWg sync.WaitGroup
				var chans []chan interface{}
				for _, task := range gjson.Get(data, "data.tasks").Array() {
					list := task.String()
					var ch = make(chan interface{})
					chans = append(chans, ch)
					err := global.BM_POOL.Submit(dealsWorker.Decorator(dealsWorker.Execute, map[string]interface{}{
						"tasks": list,
						"mode":  "normalMode",
					}, &taskWg, ch))
					if err != nil {
						return
					}
					break
				}

				taskWg.Wait()

				global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "success", "content": "================ 开始统计 =================="})

				// 获取协程返回的数据
				for _, ch := range chans {
					chResult := <-ch
					if chResult != nil {
						result := chResult.(map[string]string)
						if len(result) > 0 {
							global.BM_EVENTBUS.Publish("deals:log", result)
						}
					}
				}

				global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "success", "content": "================ 统计结束 =================="})
				global.BM_EVENTBUS.Publish("deals:log", map[string]string{"status": "info", "content": fmt.Sprintf("等待 %d 分钟进行下一轮任务", delay)})

				time.Sleep(time.Duration(delay) * time.Minute)
			}

		}

		xc.XC_CallUiThread(b.ToggleBtn, int(uintptr(unsafe.Pointer(b.ExecuteBtn))))

	}()

	return 0
}

func (b *DealsPagePage) monitorMode() {
	_, e := global.BM_CRONTAB.AddFunc("*/5 * * * * ?", func() {
		machine := global.BM_API.GetMachineInfo(global.BM_CONFIG.Section("basic").Key("serialNumberCiphertext").Value())
		if gjson.Get(machine, "data.executeMethod").String() == "webdriver_method" {
			b.FastMode = false
		} else {
			b.FastMode = true
		}
	})

	_, e = global.BM_CRONTAB.AddFunc("*/20 * * * * ?", func() {
		rankWorker := workers.NewRankWorker()
		rankWorker.Execute(map[string]interface{}{
			"website": "www.amazon.com",
		})
	})

	if e != nil {
		fmt.Println("error:", e)
	}

	global.BM_CRONTAB.Start()
}

func (b *DealsPagePage) AddData(data int) int {
	tableData := *(*map[string]interface{})(unsafe.Pointer(uintptr(data)))

	// 填充头部
	headers := tableData["headers"].([]string)

	for _, header := range headers {
		xc.XAdTable_AddColumn(b.HAdapter, header)
	}

	// 填充body
	body := tableData["body"].([]map[string]string)
	for _, bd := range body {
		item := xc.XAdTable_AddItemText(b.HAdapter, "")
		for index, header := range headers {
			xc.XAdTable_SetItemText(b.HAdapter, item, index, bd[header])
		}
	}

	b.RedrawListBoxLayout()
	return 0
}

func (b *DealsPagePage) UpdateData(data int) int {
	tableData := *(*map[string]interface{})(unsafe.Pointer(uintptr(data)))
	group := tableData["group"].(string)

	info := tableData["info"].(string)
	count := xc.XAdTable_GetCount(b.HAdapter)

	for i := 0; i < count; i++ {
		if xc.XAdTable_GetItemText(b.HAdapter, i, 1) == group {
			xc.XAdTable_SetItemText(b.HAdapter, i, 6, info)
		}
	}

	b.RedrawListBoxLayout()
	return 0
}

func (b *DealsPagePage) DeleteData(data int) int {
	group := *(*string)(unsafe.Pointer(uintptr(data)))

	count := xc.XAdTable_GetCount(b.HAdapter)
	matchCount := 0
	// 由于如果删除了其中一项之后，顺序会乱，所以先找出总共匹配的个数再一起删除
	for i := 0; i < count; i++ {
		if xc.XAdTable_GetItemText(b.HAdapter, i, 1) == group {
			matchCount++
		}
	}

	for i := 0; i < matchCount; i++ {
		for j := 0; j < xc.XAdTable_GetCount(b.HAdapter); j++ {
			if xc.XAdTable_GetItemText(b.HAdapter, j, 1) == group {
				xc.XAdTable_DeleteItem(b.HAdapter, j)
				break
			}
		}
	}

	b.RedrawListBoxLayout()
	return 0
}

func (b *DealsPagePage) updateTaskTotal(data int) int {
	result := *(*map[string]int)(unsafe.Pointer(uintptr(data)))
	b.taskTotal.SetText(fmt.Sprintf("当前任务组总数为: %d, 任务总数为: %d", result["taskGroupTotal"], result["taskTotal"]))
	b.taskTotal.Redraw()
	widget.NewLayoutEleByHandle(b.taskTotal.GetParentEle()).AdjustLayout(0)
	widget.NewLayoutEleByHandle(b.taskTotal.GetParentEle()).Redraw(true)

	return 0
}

func (b *DealsPagePage) updateFeedBack(feedback int) int {
	data := *(*map[interface{}]uint)(unsafe.Pointer(uintptr(feedback)))
	count := b.ListBox.GetCount_AD()
	if count > 0 {
		for iitem := 0; iitem < count; iitem++ {
			asin := b.ListBox.GetItemText(iitem, 1)
			val, ok := data[asin]
			if ok {
				curTotal, _ := strconv.Atoi(b.ListBox.GetItemText(iitem, 1))
				curTotal += int(val)
				xc.XAdTable_SetItemText(b.HAdapter, iitem, 3, strconv.Itoa(curTotal))
			}

		}
	}

	b.RedrawListBoxLayout()

	return 0
}
